<html lang="en">

<head th:include="templates/common :: header" />

<body>
	<div class="container" style="margin-top: 40px;">
		<div th:include="templates/common :: menu" ></div>	
		
		<div class="alert alert-success" th:if="${not #strings.isEmpty(status) and status == 'groups.create.success'}">
			<a class="close">x</a>
			<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
		</div>
		
		<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'groups.create.failure'}">
			<a class="close">x</a>
			<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
		</div>

		<div class="alert alert-success" th:if="${not #strings.isEmpty(status) and status == 'groups.update.success'}">
			<a class="close">x</a>
			<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
		</div>
		
		<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'groups.update.failure'}">
			<a class="close">x</a>
			<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
		</div>
		
		<div class="alert alert-success" th:if="${not #strings.isEmpty(status) and status == 'groups.delete.success'}">
			<a class="close">x</a>
			<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
		</div>	
		
		<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'groups.delete.failure'}">
			<a class="close">x</a>
			<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
		</div>	
		
		<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'groups.not.found'}">
			<a class="close">x</a>
			<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
		</div>
		
		<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'groups.constraint.exception'}">
			<a class="close">x</a>
			<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
		</div>
			
 		<div class="panel panel-primary" >		
	 		<div class="panel-body">				
				<div style="float:right; margin-bottom:10px;">
					<a class="btn btn-primary" th:href="@{/groups/create}" th:inline="text">
						<i class="glyphicon glyphicon-plus-sign" style="margin-right:5px;"/>[[#{groups.create}]]
					</a>
				</div>

				<form id="groupSearchForm" action="#" th:object="${searchHelper}" th:action="@{/groups/__${beginIndex}__(order=${order}, column=${column}, searchString=${searchString})}" method="get" class="form-inline">
					<div class="col-lg-3">
						<input id="searchInput" type="text" th:field="*{searchString}" autofocus="autofocus" class="form-control" th:placeholder="#{app.search.label}" />
					</div>
					<button id="sumbitSearch" type="submit" class="btn btn-primary" th:inline="text"> 
						<i class="glyphicon glyphicon-search" style="margin-right: 5px;" />[[#{app.search}]]
					</button>
				</form>
			</div>
		</div>
			
		<table class="table table-bordered table-striped table-condensed">			
			<tr>
				<th scope="col" style="text-align: center !important;">
					<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/groups/'+${currentIndex}(order=${order} , column='numericGroupName', searchString=${searchHelper.searchString})}" th:text="#{groups.table.group.name.numeric}"/>
					<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/groups/'+${currentIndex}(order=${order}, column='numericGroupName')}" th:text="#{groups.table.group.name.numeric}"/>					
				</th>
				<th scope="col" style="text-align: center !important;">
					<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/groups/'+${currentIndex}(order=${order}, column='groupName', searchString=${searchHelper.searchString})}" th:text="#{groups.table.group.name}"/>
					<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/groups/'+${currentIndex}(order=${order} , column='groupName')}" th:text="#{groups.table.group.name}"/>					
				</th>
				<th scope="col" style="text-align: center !important;"></th>
			</tr>
			<tr th:each="group : ${groups}">
				<td th:text="${group.numericGroupName}" style="text-align: center; vertical-align: middle;"></td>
				<td th:text="${group.groupName}" style="text-align: center; vertical-align: middle;"></td>							
				<td style="text-align: center; vertical-align: middle;">
					<a id="subjectsInGroupLink" class="btn btn-success btn-small" th:href="@{/groups/subjects/__${group.id}__}" th:inline="text">
						<i class="glyphicon glyphicon-list-alt icon-white" style="margin-right:5px;"/>[[#{groups.show.subjects}]]
					</a> 
					<a id="groupEditLink" class="btn btn-primary btn-small" th:href="@{/groups/edit/__${group.id}__}" th:inline="text">
						<i class="glyphicon glyphicon-edit icon-white" style="margin-right:5px;"/>[[#{app.button.edit}]]
					</a>
					<a id="groupDeleteLink" class="btn btn-danger btn-small" th:href="@{/groups/delete/__${group.id}__}"  th:inline="text" >
						<i class="glyphicon glyphicon-remove-sign" style="margin-right:5px;"/>[[#{app.button.delete}]]
					</a>
				</td>
			</tr>
		</table>
				
		<div style="text-align:center">
			<ul class="pager">
				<li class="disabled" th:if="${currentIndex == 1}"><a href="#">&lt;&lt;</a></li>
				<li class="disabled" th:if="${currentIndex == 1}"><a href="#">&lt;</a></li>
				<li th:if="${currentIndex != 1}">
					<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{/groups/__${beginIndex}__(order=${order}, column=${column}, searchString=${searchHelper.searchString})}">&lt;&lt;</a>
					<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{/groups/__${beginIndex}__(order=${order}, column=${column})}">&lt;&lt;</a>
				</li>
				<li th:if="${currentIndex != 1}">
					<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{/groups/__${currentIndex-1}__(order=${order}, column=${column}, searchString=${searchHelper.searchString})}">&lt;</a>
					<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{/groups/__${currentIndex-1}__(order=${order}, column=${column})}">&lt;</a>
				</li>

				<li class="disabled" th:if="${currentIndex == totalPages}"><a href="#">&gt;</a></li>
				<li class="disabled" th:if="${currentIndex == totalPages}"><a href="#">&gt;&gt;</a></li>
				<li th:if="${currentIndex != totalPages}">
					<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{/groups/__${currentIndex+1}__(order=${order}, column=${column}, searchString=${searchHelper.searchString})}">&gt;</a>
					<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{/groups/__${currentIndex+1}__(order=${order}, column=${column})}">&gt;</a>
				</li>
				<li th:if="${currentIndex != totalPages}">
					<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{/groups/__${endIndex}__(order=${order} , column=${column}, searchString=${searchHelper.searchString})}">&gt;&gt;</a>
					<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{/groups/__${endIndex}__(order=${order} , column=${column})}">&gt;&gt;</a>
				</li>
			</ul>
		</div>
	</div>		
</body>
</html>